﻿

using MCPlatform.MotionLib.Base;
using MCPlatform.MotionLib.Base.Models;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.AspNetCore.SignalR.Protocol;
using Panuon.WPF.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace MCPlatform.MotionLib.Factory.LeadShine
{
    public class LTImputation : IImputation
    {
        #region Fields

        protected NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();//打印日志

        public string ControlName { get; set; } = string.Empty;

        public ushort CrdNo { get { return this._crdNo; } set { this._crdNo = value; StartUp(); } }
        private ushort _cardNo = 0;

        //卡号
        private ushort _crdNo = 0;


        #endregion


        #region Properties
        public bool IsImpDone
        {
            get
            {
                return LTDMC.dmc_check_done_multicoor(_cardNo, ImputationConfig.CrdNo) == 1;
            }
            set { }

        }

        public bool IsImpBusy
        {
            get
            {
                return GetMulticoorRunState() == 0;
            }
            set { }
        }

        public bool IsImpIdle
        {
            get
            {
                return GetMulticoorRunState() == 4;
            }
            set { }
        }

        public bool IsImpPasue
        {
            get
            {
                return GetMulticoorRunState() == 1;
            }
            set { }
        }

        public bool IsImpError 
        {
            get
            {
                
                try
                {
                    ushort[] axisNumbers = ImputationConfig.AxisList;
                    foreach (ushort axisNo in axisNumbers)
                    {
                        if (axisNo >= 0)
                        {
                            ushort errorCode = 0;
                            LTDMC.nmc_get_axis_errcode(_cardNo, axisNo, ref errorCode);
                            if (errorCode > 0)
                            {
                                return true; // 一旦发现错误，立即返回  
                            }
                        }
                    }
                    return false; // 如果没有发现错误，则返回false  
                }
                catch (Exception ex)
                {
                    logger.Error("命令异常：" + "LTDMC.nmc_get_axis_errcode" + ex.Message);
                    throw new Exception("命令：" + "LTDMC.nmc_get_axis_errcode" + ex.Message + "堆栈: " + ex.StackTrace);
                }
            }
            set{ }
        }

        public bool IsImpGear
        {
            get
            {
                return GetMulticoorRunState() == 3;
            }
            set { }
        }


        public double ActualVelocity
        {
            get
            {
                try
                {
                    double vel = 0;
                    LTDMC.dmc_read_vector_speed_unit(_cardNo, ImputationConfig.CrdNo, ref vel);
                    return vel;


                }
                catch (Exception)
                {
                    logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_read_vector_speed_unit");
                    throw;
                }
            }

        }
        public ImpMotionParaModel ImputationConfig { get; set; } = new ImpMotionParaModel();
        public double XAxiPos 
        { 
            get 
            {
                if (ImputationConfig.XAxisNo<0)
                {
                    return 0;
                }
                double pos = 0;
                LTDMC.dmc_get_position_unit(_cardNo, (ushort)ImputationConfig.XAxisNo, ref pos);
                return pos;
            }

            set { }
        }
        public double YAxiPos
        {
            get
            {
                if (ImputationConfig.YAxisNo < 0)
                {
                    return 0;
                }
                double pos = 0;
                LTDMC.dmc_get_position_unit(_cardNo, (ushort)ImputationConfig.YAxisNo, ref pos);
                return pos;
            }

            set { }
        }
        public double ZAxiPos
        {
            get
            {
                if (ImputationConfig.ZAxisNo < 0)
                {
                    return 0;
                }
                double pos = 0;
                LTDMC.dmc_get_position_unit(_cardNo, (ushort)ImputationConfig.ZAxisNo, ref pos);
                return pos;
            }

            set { }
        }
        public double UAxiPos
        {
            get
            {
                if (ImputationConfig.UAxisNo < 0)
                {
                    return 0;
                }
                double pos = 0;
                LTDMC.dmc_get_position_unit(_cardNo, (ushort)ImputationConfig.UAxisNo, ref pos);
                return pos;
            }

            set { }
        }
        public double VAxiPos
        {
            get
            {
                if (ImputationConfig.VAxisNo < 0)
                {
                    return 0;
                }
                double pos = 0;
                LTDMC.dmc_get_position_unit(_cardNo, (ushort)ImputationConfig.VAxisNo, ref pos);
                return pos;
            }

            set { }
        }
        public double WAxiPos
        {
            get
            {
                if (ImputationConfig.WAxisNo < 0)
                {
                    return 0;
                }
                double pos = 0;
                LTDMC.dmc_get_position_unit(_cardNo, (ushort)ImputationConfig.WAxisNo, ref pos);
                return pos;
            }

            set { }
        }


        #endregion

        #region CTOR
        public LTImputation(ImpMotionParaModel imputationConfig)
        {
            ImputationConfig = imputationConfig;
        }

        public LTImputation()
        {

        }


        private void StartUp()
        {
            SetImpProfile();
           
        }


        #endregion

        #region 插补状态控制

        public short SetVelocity(double velocity)
        {
            try
            {
               
                short result = LTDMC.dmc_set_vector_profile_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.MinVelocity, velocity,
                    ImputationConfig.Acc, ImputationConfig.Dec, ImputationConfig.StopVelocity);
                if (result > 0) return result;
                result = LTDMC.dmc_set_vector_s_profile(_cardNo, ImputationConfig.CrdNo, ImputationConfig.SMode, ImputationConfig.SPara);
                logger.Info("执行：setProfile");
                return result;
            }
            catch (Exception ex)
            {
                logger.Error("命令异常：" + "LTDMC.dmc_set_vector_profile_unit" + ex.Message);
                throw new Exception("命令：" + "LTDMC.dmc_set_vector_profile_unit" + ex.Message + "堆栈: " + ex.StackTrace);
            }

        }

        public short Reset()
        {
            try
            {
                logger.Info("轴名称:{ControlName},执行：Reset");
                if (ImputationConfig.XAxisNo>=0)  LTDMC.nmc_clear_axis_errcode(_cardNo, (ushort)ImputationConfig.XAxisNo);
                if (ImputationConfig.YAxisNo >= 0) LTDMC.nmc_clear_axis_errcode(_cardNo, (ushort)ImputationConfig.YAxisNo);
                if (ImputationConfig.ZAxisNo >= 0) LTDMC.nmc_clear_axis_errcode(_cardNo, (ushort)ImputationConfig.ZAxisNo);
                if (ImputationConfig.UAxisNo >= 0) LTDMC.nmc_clear_axis_errcode(_cardNo, (ushort)ImputationConfig.UAxisNo);
                if (ImputationConfig.VAxisNo >= 0) LTDMC.nmc_clear_axis_errcode(_cardNo, (ushort)ImputationConfig.VAxisNo);
                if (ImputationConfig.WAxisNo >= 0) LTDMC.nmc_clear_axis_errcode(_cardNo, (ushort)ImputationConfig.WAxisNo);
                return 0;
                
            }
            catch (Exception)
            {
                logger.Error("轴名称:{ControlName},执行：Reset");
                throw;
            }
        }


        /// <summary>
        /// 坐标系插补运动速度
        /// </summary>
        /// <param name="vel">速度值</param>
        /// <returns>错误码</returns>

        public short GetMulticoorCurrentVeocity(ref double vel)
        {
            try
            {

                return LTDMC.dmc_read_vector_speed_unit(_cardNo, ImputationConfig.CrdNo, ref vel);


            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_read_vector_speed_unit，当前速度{vel}");
                throw;
            }
        }


        /// <summary>
        /// 坐标系内全部轴停止
        /// </summary>
        /// <returns>错误码</returns>
        public short StopMulticoor()
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_stop_multicoor");
                return LTDMC.dmc_stop_multicoor(_cardNo, ImputationConfig.CrdNo, 0);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_stop_multicoor");
                throw;
            }
        }

        /// <summary>
        /// 获取坐标系的插补运动状态
        /// </summary>
        /// <returns>
        /// 返回值：运动状态，0：运动中，1：暂停中，2：正常停止，3：未启动，4：空闲
        ///说明：1)该函数适用于所有插补
        ///2)“运动中”指的是插补运动正在进行
        ///3)“暂停中”指的运动未完成时暂停指令生效后的状态，调用startlist可重新启动
        ///4)“正常停止”指的是缓冲区内运动都执行完成后运动停止
        ///5)“未启动”指打开缓冲区后轴已被坐标系占用但还没开始运动的状态，此时被加坐标系
        ///中的轴不能再被调用
        ///6)“空闲”指坐标系未打开的状态，调用stoplist后进入此状态
        ///</returns>
        public short GetMulticoorRunState()
        {
            try
            {
                //logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_get_run_state");
                return LTDMC.dmc_conti_get_run_state(_cardNo, ImputationConfig.CrdNo);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_get_run_state");
                throw;
            }
        }

        #endregion
    

        #region 设置速度


        /// <summary>
        /// 设置插补运动速度曲线
        /// </summary>       
        /// <returns>错误码</returns>
        public short SetImpProfile()
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_set_vector_profile_unit，最小速度：{ImputationConfig.MinVelocity}，最大速度：{ImputationConfig.MaxVelocity}，加速度：{ImputationConfig.Acc}，减速度：{ImputationConfig.Dec}，停止速度：{ImputationConfig.StopVelocity}");
                return LTDMC.dmc_set_vector_profile_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.MinVelocity, ImputationConfig.MaxVelocity, ImputationConfig.Acc, ImputationConfig.Dec, ImputationConfig.StopVelocity);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_set_vector_profile_unit，最小速度：{ImputationConfig.MinVelocity}，最大速度：{ImputationConfig.MaxVelocity}，加速度：{ImputationConfig.Acc}，减速度：{ImputationConfig.Dec}，停止速度：{ImputationConfig.StopVelocity}");
                throw;
            }
        }


        /// <summary>
        /// 读取插补运动速度曲线
        /// </summary>      
        /// <param name="minVelocity">最小速度,单位:unis/s</param>
        /// <param name="maxVelocity">最大速度,单位:unis/s</param>
        /// <param name="acc">加速度,单位:s</param>
        /// <param name="dec">减速度,单位:s</param>
        /// <param name="stopVelocity">停止速度,单位:unis/s</param>
        /// <returns>错误码</returns>
        public short GetImpProfile(ref double minVelocity, ref double maxVelocity, ref double acc, ref double dec, ref double stopVelocity)
        {
            try
            {

                var res = LTDMC.dmc_get_vector_profile_unit(_cardNo, ImputationConfig.CrdNo, ref minVelocity, ref maxVelocity, ref acc, ref dec, ref stopVelocity);
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_get_vector_profile_unit，最小速度：{minVelocity}，最大速度：{ImputationConfig.MaxVelocity}，加速度：{ImputationConfig.Acc}，减速度：{ImputationConfig.Dec}，停止速度：{ImputationConfig.StopVelocity}");
                return res;
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_get_vector_profile_unit，最小速度：{minVelocity}，最大速度：{ImputationConfig.MaxVelocity}，加速度：{ImputationConfig.Acc}，减速度：{ImputationConfig.Dec}，停止速度：{ImputationConfig.StopVelocity}");
                throw;
            }
        }


        /// <summary>
        /// 设置插补运动速度曲线的平滑时间
        /// </summary>
        /// <returns>错误码</returns>
        public short SetImpSProfile()
        {
            try
            {
                List<short> axisList = new List<short> { ImputationConfig.XAxisNo, ImputationConfig.YAxisNo, ImputationConfig.ZAxisNo, ImputationConfig.UAxisNo, ImputationConfig.VAxisNo, ImputationConfig.WAxisNo };

                // 使用LINQ的Where方法来过滤出大于0的元素，并转换为数组  
                ImputationConfig.AxisList = axisList
                .Where(axis => axis > 0) // 先过滤出大于0的元素  
                .Cast<ushort>() // 再进行类型转换（这里假设没有负数，所以不会抛出异常）  
                .ToArray(); // 转换为ushort数组 

                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_set_vector_s_profile，s_mode：{ImputationConfig.SMode}，s_para：{ImputationConfig.SPara}");
                return LTDMC.dmc_set_vector_s_profile(_cardNo, ImputationConfig.CrdNo, ImputationConfig.SMode, ImputationConfig.SPara);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_set_vector_s_profile，s_mode：{ImputationConfig.SMode}，s_para：{ImputationConfig.SPara}");
                throw;
            }
        }


        /// <summary>
        /// 读取插补运动速度曲线的平滑时间
        /// </summary>      
        /// <param name="s_para">平滑时间，单位s,范围：0-1</param>
        /// <param name="s_mode">保留参数，固定值0</param>
        /// <returns>错误码</returns>
        public short GetImpSProfile(ref double s_para, ushort s_mode = 0)
        {
            try
            {
                var res = LTDMC.dmc_get_vector_s_profile(_cardNo, ImputationConfig.CrdNo, s_mode, ref s_para);
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_get_vector_s_profile，s_mode：{s_mode}，s_para：{s_para}");
                return res;
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_get_vector_s_profile，s_mode：{s_mode}，s_para：{s_para}");
                throw;
            }
        }


        #endregion


        #region 插补运动

        /// <summary>
        /// 直线插补绝对运动
        /// </summary>  
        /// <param name="targetPos">目标位置，单位：unit</param>
        /// <returns>错误码</returns>
        public short ImpLineAbsMove(double[] targetPos)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_line_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},绝对直线插补");
                return LTDMC.dmc_line_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, 1);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_line_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},绝对直线插补");
                throw;
            }
        }

        public async Task<(bool, short, string)> ImpLineAbsMoveAsync(double[] targetPos,CancellationToken cancellationToken, ManualResetEvent manualResetEvent)
        {

            try
            {
                (bool, short, string) result = (true, 0, "Done");
                if (IsImpBusy)
                {
                    return (false, 0, "Coordinate is Busy");
                }


                var res = ImpLineAbsMove(targetPos);
                if (res != 0)
                {
                    return (false, res, "Abs Move Error");
                }
                await Task.Run(async () =>
                {
                    while (!IsImpDone && !cancellationToken.IsCancellationRequested)
                    {
                        manualResetEvent.WaitOne();
                        await Task.Delay(10);
                        if (IsImpError)
                        {
                            result = (false, 999, "Axis Error");
                            break;
                        }

                    }
                });

                return result;

            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 直线插补相对运动
        /// </summary>      
        /// <param name="targetPos">目标位置，单位：unit</param>
        /// <returns>错误码</returns>
        public short ImpLineRelMove(double[] targetPos)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_line_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length} ,相对直线插补");
                return LTDMC.dmc_line_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, 0);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_line_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},相对直线插补");
                throw;
            }
        }

        public async Task<(bool, short, string)> ImpLineRelMoveAsync(double[] targetPos, CancellationToken cancellationToken, ManualResetEvent manualResetEvent)
        {

            try
            {
                (bool, short, string) result = (true, 0, "Done");
                if (IsImpBusy)
                {
                    return (false, 0, "Coordinate is Busy");
                }


                var res = ImpLineRelMove(targetPos);
                if (res != 0)
                {
                    return (false, res, "Abs Move Error");
                }
                await Task.Run(async () =>
                {
                    while (!IsImpDone && !cancellationToken.IsCancellationRequested)
                    {
                        manualResetEvent.WaitOne();
                        await Task.Delay(10);
                        if (IsImpError)
                        {
                            result = (false, 999, "Axis Error");
                            break;
                        }

                    }
                });

                return result;

            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 基于圆心圆弧螺旋插补绝对运动
        /// </summary>      
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="centerPos">圆心位置数组，单位:unit</param>
        /// <param name="arcDir">圆弧方向，0：顺时针，1：逆时针</param>
        /// <param name="circle">圈数，便是螺旋线插补圈数，0代表0圈，1代表1圈</param>
        /// <returns>错误码</returns>
        public short ImpArcCenterAbsMove(double[] targetPos, double[] centerPos, ushort arcDir = 1, int circle = 0)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆心位置数组：{centerPos}，圈数：{circle}，绝对圆弧插补");
                return LTDMC.dmc_arc_move_center_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, centerPos, arcDir, circle, 1);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆心位置数组：{centerPos}，圈数：{circle}，绝对圆弧插补");
                throw;
            }
        }


        /// <summary>
        /// 基于圆心圆弧螺旋插补相对运动
        /// </summary>      
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="centerPos">圆心位置数组，单位:unit</param>
        /// <param name="arcDir">圆弧方向，0：顺时针，1：逆时针</param>
        /// <param name="circle">圈数，便是螺旋线插补圈数，0代表0圈，1代表1圈</param>
        /// <returns>错误码</returns>
        public short ImpArcCenterRelMove(double[] targetPos, double[] centerPos, ushort arcDir = 1, int circle = 0)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆心位置数组：{centerPos}，圈数：{circle}，相对圆弧插补");
                return LTDMC.dmc_arc_move_center_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, centerPos, arcDir, circle, 0);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆心位置数组：{centerPos}，圈数：{circle}，相对圆弧插补");
                throw;
            }
        }

        /// <summary>
        /// 基于半径圆弧螺旋插补相对运动
        /// </summary>      
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="arcRadius">圆弧半径值（负值为优弧，正值为劣弧）,单位：unit</param>
        /// <param name="arcDir">圆弧方向，0：顺时针，1：逆时针</param>
        /// <param name="circle">圈数</param>  
        /// <returns>错误码</returns>

        public short ImpArcRediusRelMove(double[] targetPos, double arcRadius, ushort arcDir = 1, int circle = 0)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_radius_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆弧半径：{arcRadius}，圈数：{circle}，相对圆弧插补");
                return LTDMC.dmc_arc_move_radius_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, arcRadius, arcDir, circle, 0);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_radius_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆弧半径：{arcRadius}，圈数：{circle}，相对圆弧插补");
                throw;
            }
        }


        /// <summary>
        /// 基于半径圆弧螺旋插补绝对运动
        /// </summary>    
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="arcRadius">圆弧半径值（负值为优弧，正值为劣弧）,单位：unit</param>
        /// <param name="arcDir">圆弧方向，0：顺时针，1：逆时针</param>
        /// <param name="circle">圈数</param>       
        /// <returns>错误码</returns>

        public short ImpArcRediusAbsMove(double[] targetPos, double arcRadius, ushort arcDir = 1, int circle = 0)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_radius_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆弧半径：{arcRadius}，圈数：{circle}，绝对圆弧插补");
                return LTDMC.dmc_arc_move_radius_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, arcRadius, arcDir, circle, 1);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_radius_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆弧半径：{arcRadius}，圈数：{circle}，绝对圆弧插补");
                throw;
            }
        }


        /// <summary>
        /// 基于三点圆弧螺旋插补相对运动
        /// </summary>    
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="midPos">圆心位置数组，单位:unit</param>      
        /// <param name="circle">圈数，螺旋线插补圈数，0代表0圈，1代表1圈</param>
        /// <returns>错误码</returns>
        public short ImpArc3PointRelMove(double[] targetPos, double[] midPos, int circle = 0)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，中间位置数组：{midPos}，圈数：{circle}，相对圆弧插补");
                return LTDMC.dmc_arc_move_3points_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, midPos, circle, 0);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，中间位置数组：{midPos}，圈数：{circle}，相对圆弧插补");
                throw;
            }
        }


        /// <summary>
        /// 基于三点圆弧螺旋插补绝对运动
        /// </summary>   
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="midPos">圆心位置数组，单位:unit</param>      
        /// <param name="circle">圈数，螺旋线插补圈数，0代表0圈，1代表1圈</param>
        /// <returns>错误码</returns>
        public short ImpArc3PointAbsMove(double[] targetPos, double[] midPos, int circle = 0)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，中间位置数组：{midPos}，圈数：{circle}，绝对圆弧插补");
                return LTDMC.dmc_arc_move_3points_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, midPos, circle, 1);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，中间位置数组：{midPos}，圈数：{circle}，绝对圆弧插补");
                throw;
            }
        }


        /// <summary>
        /// 矩形插补绝对运动
        /// </summary>   
        /// <param name="targetPos">对角位置数组，单位:unit</param>
        /// <param name="markPos">矩形方向标记位置数组，单位：unit</param>
        /// <param name="count">行数/圈数</param>
        /// <param name="recMode">矩形插补模式，0：逐行，1：渐开线</param>
        /// <returns>错误码</returns>
        public short ImpRectangleAbsMove(double[] targetPos, double[] markPos, int count, ushort recMode)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},对角位置:{targetPos}，矩形方向标记位置数组：{markPos}，圈数：{count}，绝对矩形插补");
                return LTDMC.dmc_rectangle_move_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, markPos, count, recMode, 1);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},对角位置:{targetPos}，矩形方向标记位置数组：{markPos}，圈数：{count}，绝对矩形插补");
                throw;
            }
        }


        /// <summary>
        /// 矩形插补相对运动
        /// </summary> 
        /// <param name="targetPos">对角位置数组，单位:unit</param>
        /// <param name="markPos">矩形方向标记位置数组，单位：unit</param>
        /// <param name="count">行数/圈数</param>
        /// <param name="recMode">矩形插补模式，0：逐行，1：渐开线</param>
        /// <returns>错误码</returns>
        public short ImpRectangleRelMove(double[] targetPos, double[] markPos, int count, ushort recMode)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},对角位置:{targetPos}，矩形方向标记位置数组：{markPos}，圈数：{count}，绝对矩形插补");
                return LTDMC.dmc_rectangle_move_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, markPos, count, recMode, 0);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},对角位置:{targetPos}，矩形方向标记位置数组：{markPos}，圈数：{count}，绝对矩形插补");
                throw;
            }
        }

        /// <summary>
        /// 直线插补参与插补轴数量设置
        /// </summary>    
        /// <param name="enableNum">使能轴数量，0：最多只有3个轴参与直线插补，其他轴跟随运动；1：坐标系所有轴都参与直线插补</param>
        /// <returns></returns>
        public short ImpEnableLineMoveAxisNum(ushort enableNum)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_axis_follow_line_enable，使能直线插补轴数量：{enableNum}");
                return LTDMC.dmc_axis_follow_line_enable(_cardNo, ImputationConfig.CrdNo, enableNum);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_axis_follow_line_enable，使能直线插补轴数量：{enableNum}");
                throw;
            }
        }


        /// <summary>
        /// 椭圆插补相对运动
        /// </summary>
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="centerPos">椭圆圆心位置数组，单位:unit</param>
        /// <param name="aAxisLen">长半轴长度</param>
        /// <param name="bAxisLen">短半轴长度</param>
        /// <param name="dir">插补方向，0顺时针插补，1逆时针插补</param>
        /// <returns>错误码</returns>
        public short ImpEllipseRelMove(double[] targetPos, double[] centerPos, double aAxisLen, double bAxisLen, ushort dir)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，椭圆圆心位置数组：{centerPos}，长半轴长度：{aAxisLen}，短半轴长度：{bAxisLen}，相对椭圆插补");
                return LTDMC.dmc_ellipse_move(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, centerPos, aAxisLen, bAxisLen, dir, 0);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，椭圆圆心位置数组：{centerPos}，长半轴长度：{aAxisLen}，短半轴长度：{bAxisLen}，相对椭圆插补");
                throw;
            }
        }


        /// <summary>
        /// 椭圆插补绝对运动
        /// </summary>     
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="centerPos">椭圆圆心位置数组，单位:unit</param>
        /// <param name="aAxisLen">长半轴长度</param>
        /// <param name="bAxisLen">短半轴长度</param>
        /// <param name="dir">插补方向，0顺时针插补，1逆时针插补</param>
        /// <returns>错误码</returns>
        public short ImpEllipseAbsMove(double[] targetPos, double[] centerPos, double aAxisLen, double bAxisLen, ushort dir)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，椭圆圆心位置数组：{centerPos}，长半轴长度：{aAxisLen}，短半轴长度：{bAxisLen}，相对椭圆插补");
                return LTDMC.dmc_ellipse_move(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, centerPos, aAxisLen, bAxisLen, dir, 1);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，椭圆圆心位置数组：{centerPos}，长半轴长度：{aAxisLen}，短半轴长度：{bAxisLen}，相对椭圆插补");
                throw;
            }
        }

        /// <summary>
        /// 设置切向跟随参数
        /// </summary>      
        /// <param name="axisNo">跟随轴号</param>
        /// <param name="followCurve">跟随轴曲线类型，0跟随圆弧；1跟随椭圆</param>
        /// <param name="rotDir">跟随轴旋转方向</param>
        /// <param name="degreeEquiv">角度当量，单位pulse/degree,跟随轴没旋转一度，控制卡下发的脉冲数</param>
        /// <returns>错误码</returns>
        public short SetTangentFollow(ushort axisNo, ushort followCurve, ushort rotDir, double degreeEquiv)
        {
            try
            {
                logger.Info($"设置切向跟随参数，卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_set_tangent_follow，跟随轴号：{axisNo}，跟随曲线类型：{followCurve},跟随旋转方向:{rotDir}，角度当量：{degreeEquiv}");
                return LTDMC.dmc_set_tangent_follow(_cardNo, ImputationConfig.CrdNo, axisNo, followCurve, rotDir, degreeEquiv);
            }
            catch (Exception)
            {
                logger.Error($"设置切向跟随参数，卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_set_tangent_follow，跟随轴号：{axisNo}，跟随曲线类型：{followCurve},跟随旋转方向:{rotDir}，角度当量：{degreeEquiv}");
                throw;
            }
        }

        /// <summary>
        /// 读取切向跟随参数
        /// </summary>       
        /// <param name="axisNo">跟随轴号</param>
        /// <param name="followCurve">跟随轴曲线类型，0跟随圆弧；1跟随椭圆</param>
        /// <param name="rotDir">跟随轴旋转方向</param>
        /// <param name="degreeEquiv">角度当量，单位pulse/degree,跟随轴没旋转一度，控制卡下发的脉冲数</param>
        /// <returns>错误码</returns>
        public short GetTangentFollow(ref ushort axisNo, ref ushort followCurve, ref ushort rotDir, ref double degreeEquiv)
        {
            try
            {
                var res = LTDMC.dmc_get_tangent_follow_param(_cardNo, ImputationConfig.CrdNo, ref axisNo, ref followCurve, ref rotDir, ref degreeEquiv);
                logger.Info($"读取切向跟随参数，卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_set_tangent_follow，跟随轴号：{axisNo}，跟随曲线类型：{followCurve},跟随旋转方向:{rotDir}，角度当量：{degreeEquiv}");
                return res;
            }
            catch (Exception)
            {
                logger.Error($"读取切向跟随参数，卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_set_tangent_follow，跟随轴号：{axisNo}，跟随曲线类型：{followCurve},跟随旋转方向:{rotDir}，角度当量：{degreeEquiv}");
                throw;
            }
        }

        #endregion


        #region 连续插补

        /// <summary>
        /// 打开连续插补缓冲区
        /// </summary>       
        /// <returns>错误码</returns>
        public short ContiOpenList()
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_open_list，轴数：{ImputationConfig.AxisNum}，轴号列表：{ImputationConfig.AxisList.Length}");
                return LTDMC.dmc_conti_open_list(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_open_list，轴数：{ImputationConfig.AxisNum}，轴号列表：{ImputationConfig.AxisList.Length}");
                throw;
            }
        }


        /// <summary>
        /// 开始连续插补
        /// </summary>  
        /// <returns>错误码</returns>
        public short ContiStartList()
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_start_list");
                return LTDMC.dmc_conti_start_list(_cardNo, ImputationConfig.CrdNo);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_open_list");
                throw;
            }
        }


        /// <summary>
        /// 开始连续插补
        /// </summary>   
        /// <returns>错误码</returns>
        public short ContiCloseList()
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_close_list");
                return LTDMC.dmc_conti_close_list(_cardNo, ImputationConfig.CrdNo);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_close_list");
                throw;
            }
        }


        /// <summary>
        /// 暂停连续插补
        /// </summary>      
        /// <returns>错误码</returns>
        public short ContiPauseList()
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_pause_list");
                return LTDMC.dmc_conti_pause_list(_cardNo, ImputationConfig.CrdNo);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_pause_list");
                throw;
            }
        }


        /// <summary>
        /// 停止连续插补
        /// </summary>     
        /// <param name="stopMode">停止模式，0：减速停止，1：立即停止</param>
        /// <returns>错误码</returns>
        public short ContiStopList(ushort stopMode = 0)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_stop_list,停止模式：{stopMode}");
                return LTDMC.dmc_conti_stop_list(_cardNo, ImputationConfig.CrdNo, stopMode);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_stop_list,停止模式：{stopMode}");
                throw;
            }
        }


        /// <summary>
        /// 连续插补中暂停延迟
        /// </summary>       
        /// <param name="delayTime">延迟时间，单位：s</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>
        public short ContiPauseListDelay(double delayTime, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_delay,延迟时间：{delayTime}，标号：{mark}");
                return LTDMC.dmc_conti_delay(_cardNo, ImputationConfig.CrdNo, delayTime, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_delay,延迟时间：{delayTime}，标号：{mark}");
                throw;
            }
        }

        /// <summary>
        /// 动态调整连续插补速度比例
        /// </summary>
        /// <param name="ImputationConfig.CrdNo">坐标系号，取值范围：0-7</param>
        /// <param name="percent">速度比例，取值范围：0-2.0</param>
        /// <returns>错误码</returns>
        public short ContiChangeSpeedRatio(double percent)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_change_speed_ratio,速度比例：{percent}");
                return LTDMC.dmc_conti_change_speed_ratio(_cardNo, ImputationConfig.CrdNo, percent);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_change_speed_ratio,速度比例：{percent}");
                throw;
            }
        }


        /// <summary>
        /// 连续直线插补绝对运动
        /// </summary>
        /// <param name="targetPos">目标位置</param>
        /// <param name="mark">序号</param>
        /// <returns>错误码</returns>
        public async Task<(bool, short, string)> ContiImpLineAbsMoveAsync(double[] targetPos, int mark, CancellationToken cancellationToken, ManualResetEvent manualResetEvent)
        {

            try
            {
                (bool, short, string) result = (true, 0, "Done");
                if (IsImpBusy)
                {
                    return (false, 0, "Coordinate is Busy");
                }

                //1.先打开缓存区
                var res = ContiOpenList();

                //2.直线相对插补
                res = ContiImpLineAbsMove(targetPos, mark);
                //3.开始运行
                res = ContiStartList();
                //4.关闭缓冲区
                res = ContiCloseList();
                if (res != 0)
                {
                    return (false, res, "ContiImpLineAbsMove Error");
                }
                await Task.Run(async () =>
                {
                    while (!IsImpDone && !cancellationToken.IsCancellationRequested)
                    {
                        manualResetEvent.WaitOne();
                        await Task.Delay(10);
                        if (IsImpError)
                        {
                            result = (false, 999, "Axis Error");
                            break;
                        }

                    }
                });

                //关闭坐标系
                ContiStopList();
                return result;

            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 连续直线插补绝对运动
        /// </summary>  
        /// <param name="targetPos">目标位置，单位：unit</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>
        public short ContiImpLineAbsMove(double[] targetPos, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_line_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},标号:{mark},绝对直线插补");
                return LTDMC.dmc_conti_line_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, 1, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_line_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},标号:{mark},绝对直线插补");
                throw;
            }
        }



        /// <summary>
        /// 连续直线插补相对运动
        /// </summary>
        /// <param name="targetPos">目标位置</param>
        /// <param name="mark">序号</param>
        /// <returns>错误码</returns>
        public async Task<(bool, short, string)> ContiImpLineRelMoveAsync(double[] targetPos,int mark, CancellationToken cancellationToken, ManualResetEvent manualResetEvent)
        {

            try
            {
                (bool, short, string) result = (true, 0, "Done");
                if (IsImpBusy)
                {
                    return (false, 0, "Coordinate is Busy");
                }

                //1.先打开缓存区
                var res = ContiOpenList();

                //2.直线相对插补
                res = ContiImpLineRelMove(targetPos, mark);
                //3.开始运行
                res = ContiStartList();
                //4.关闭缓冲区
                res = ContiCloseList();

               
                if (res != 0)
                {
                    return (false, res, "ContiImpLineRelMove Error");
                }
                await Task.Run(async () =>
                {
                    while (!IsImpDone && !cancellationToken.IsCancellationRequested)
                    {
                        manualResetEvent.WaitOne();
                        await Task.Delay(10);
                        if (IsImpError)
                        {
                            result = (false, 999, "Axis Error");
                            break;
                        }

                    }
                });
                
                //关闭坐标系
                ContiStopList();
                return result;

            }
            catch (Exception)
            {

                throw;
            }
        }




        /// <summary>
        /// 连续直线插补相对运动
        /// </summary>   
        /// <param name="targetPos">目标位置，单位：unit</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>
        public short ContiImpLineRelMove(double[] targetPos, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_line_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},标号:{mark},相对直线插补");
                return LTDMC.dmc_conti_line_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, 0, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_line_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},标号:{mark},相对直线插补");
                throw;
            }
        }


        /// <summary>
        /// 连续插补基于圆心圆弧螺旋插补绝对运动
        /// </summary>    
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="centerPos">圆心位置数组，单位:unit</param>
        /// <param name="arcDir">圆弧方向，0：顺时针，1：逆时针</param>
        /// <param name="circle">圈数，便是螺旋线插补圈数，0代表0圈，1代表1圈</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>
        public short ContiImpArcCenterAbsMove(double[] targetPos, double[] centerPos, ushort arcDir, int circle, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆心位置数组：{centerPos}，圈数：{circle}，标号：{mark}，绝对圆弧插补");
                return LTDMC.dmc_conti_arc_move_center_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, centerPos, arcDir, circle, 1, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆心位置数组：{centerPos}，圈数：{circle}，标号：{mark}，绝对圆弧插补");
                throw;
            }
        }


        /// <summary>
        /// 连续插补基于圆心圆弧螺旋插补相对运动
        /// </summary> 
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="centerPos">圆心位置数组，单位:unit</param>
        /// <param name="arcDir">圆弧方向，0：顺时针，1：逆时针</param>
        /// <param name="circle">圈数，便是螺旋线插补圈数，0代表0圈，1代表1圈</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>
        public short ContiImpArcCenterRelMove(double[] targetPos, double[] centerPos, ushort arcDir, int circle, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆心位置数组：{centerPos}，圈数：{circle}，标号：{mark}，相对圆弧插补");
                return LTDMC.dmc_conti_arc_move_center_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, centerPos, arcDir, circle, 0, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_arc_move_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆心位置数组：{centerPos}，圈数：{circle}，标号：{mark}，相对圆弧插补");
                throw;
            }
        }


        /// <summary>
        /// 基于半径圆弧螺旋连续插补相对运动
        /// </summary> 
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="arcRadius">圆弧半径值（负值为优弧，正值为劣弧）,单位：unit</param>
        /// <param name="arcDir">圆弧方向，0：顺时针，1：逆时针</param>
        /// <param name="circle">圈数</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>

        public short ContiImpArcRediusRelMove(double[] targetPos, double arcRadius, ushort arcDir, int circle, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_arc_move_radius_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆弧半径：{arcRadius}，圈数：{circle}，标号：{mark},相对圆弧插补");
                return LTDMC.dmc_conti_arc_move_radius_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, arcRadius, arcDir, circle, 0, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_arc_move_radius_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆弧半径：{arcRadius}，圈数：{circle}，标号：{mark},相对圆弧插补");
                throw;
            }
        }


        /// <summary>
        /// 基于半径圆弧螺旋连续插补绝对运动
        /// </summary>  
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="arcRadius">圆弧半径值（负值为优弧，正值为劣弧）,单位：unit</param>
        /// <param name="arcDir">圆弧方向，0：顺时针，1：逆时针</param>
        /// <param name="circle">圈数</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>

        public short ContiImpArcRediusAbsMove(double[] targetPos, double arcRadius, ushort arcDir, int circle, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_arc_move_radius_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆弧半径：{arcRadius}，圈数：{circle}，标号：{mark},绝对圆弧插补");
                return LTDMC.dmc_conti_arc_move_radius_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, arcRadius, arcDir, circle, 1, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_arc_move_radius_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，圆弧半径：{arcRadius}，圈数：{circle}，标号：{mark},绝对圆弧插补");
                throw;
            }
        }


        /// <summary>
        /// 基于三点圆弧螺旋连续插补相对运动
        /// </summary>
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="midPos">圆心位置数组，单位:unit</param>      
        /// <param name="circle">圈数，螺旋线插补圈数，0代表0圈，1代表1圈</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>
        public short ContiImpArc3PointRelMove(double[] targetPos, double[] midPos, int circle, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_movdmc_conti_arc_move_3points_unite_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，中间位置数组：{midPos}，圈数：{circle}，标号{mark},相对圆弧插补");
                return LTDMC.dmc_conti_arc_move_3points_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, midPos, circle, 0, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_arc_move_3points_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，中间位置数组：{midPos}，圈数：{circle}，标号{mark},相对圆弧插补");
                throw;
            }
        }

        /// <summary>
        /// 基于三点圆弧螺旋连续插补绝对运动
        /// </summary>
        /// <param name="targetPos">目标位置数组，单位:unit</param>
        /// <param name="midPos">圆心位置数组，单位:unit</param>      
        /// <param name="circle">圈数，螺旋线插补圈数，0代表0圈，1代表1圈</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>
        public short ContiImpArc3PointAbsMove(double[] targetPos, double[] midPos, int circle, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_arc_movdmc_conti_arc_move_3points_unite_center_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，中间位置数组：{midPos}，圈数：{circle}，标号{mark},绝对圆弧插补");
                return LTDMC.dmc_conti_arc_move_3points_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, midPos, circle, 1, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_arc_move_3points_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},目标位置:{targetPos}，中间位置数组：{midPos}，圈数：{circle}，标号{mark},绝对圆弧插补");
                throw;
            }
        }


        /// <summary>
        /// 连续插补中矩形插补绝对运动
        /// </summary>
        /// <param name="targetPos">对角位置数组，单位:unit</param>
        /// <param name="markPos">矩形方向标记位置数组，单位：unit</param>
        /// <param name="count">行数/圈数</param>
        /// <param name="recMode">矩形插补模式，0：逐行，1：渐开线</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>
        public short ContiImpRectangleAbsMove(double[] targetPos, double[] markPos, int count, ushort recMode, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_rectangle_move_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},对角位置:{targetPos}，矩形方向标记位置数组：{markPos}，圈数：{count}，标号：{mark},绝对矩形插补");
                return LTDMC.dmc_conti_rectangle_move_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, markPos, count, recMode, 1, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_rectangle_move_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},对角位置:{targetPos}，矩形方向标记位置数组：{markPos}，圈数：{count}，标号：{mark},绝对矩形插补");
                throw;
            }
        }

        /// <summary>
        /// 连续插补中矩形插补相对运动
        /// </summary>
        /// <param name="markPos">矩形方向标记位置数组，单位：unit</param>
        /// <param name="count">行数/圈数</param>
        /// <param name="recMode">矩形插补模式，0：逐行，1：渐开线</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>
        public short ContiImpRectangleRelMove(double[] targetPos, double[] markPos, int count, ushort recMode, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_rectangle_move_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},对角位置:{targetPos}，矩形方向标记位置数组：{markPos}，圈数：{count}，标号：{mark},相对矩形插补");
                return LTDMC.dmc_conti_rectangle_move_unit(_cardNo, ImputationConfig.CrdNo, ImputationConfig.AxisNum, ImputationConfig.AxisList, targetPos, markPos, count, recMode, 0, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_rectangle_move_unit，ImputationConfig.AxisNum：{ImputationConfig.AxisNum}，ImputationConfig.AxisList：{ImputationConfig.AxisList.Length},对角位置:{targetPos}，矩形方向标记位置数组：{markPos}，圈数：{count}，标号：{mark},相对矩形插补");
                throw;
            }
        }

        /// <summary>
        /// 连续插补中控制指定轴绝对运动
        /// </summary>
        /// <param name="axis">指定轴号</param>
        /// <param name="dist">目标位置</param>
        /// <param name="mode">模式，0：暂停启动，1：直接启动</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>
        public short ContiAxisAbsMove(ushort axis, double dist, ushort mode, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_pmove_unit，轴号{axis}，目标位置：{dist},模式：{mode}，标号：{mark}，绝对模式");
                return LTDMC.dmc_conti_pmove_unit(_cardNo, ImputationConfig.CrdNo, axis, dist, 1, mode, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_pmove_unit，轴号{axis}，目标位置：{dist},模式：{mode}，标号：{mark}，绝对模式");
                throw;
            }
        }


        /// <summary>
        /// 连续插补中控制指定轴相对运动
        /// </summary>
        /// <param name="axis">指定轴号</param>
        /// <param name="dist">目标位置</param>
        /// <param name="mode">模式，0：暂停启动，1：直接启动</param>
        /// <param name="mark">标号，任意指定，0表示自动编号</param>
        /// <returns>错误码</returns>
        public short ContiAxisRelMove(ushort axis, double dist, ushort mode, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_pmove_unit，轴号{axis}，目标位置：{dist},模式：{mode}，标号：{mark}，相对模式");
                return LTDMC.dmc_conti_pmove_unit(_cardNo, ImputationConfig.CrdNo, axis, dist, 0, mode, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo}，坐标系：{ImputationConfig.CrdNo},执行：dmc_conti_pmove_unit，轴号{axis}，目标位置：{dist},模式：{mode}，标号：{mark}，相对模式");
                throw;
            }
        }


        /// <summary>
        /// 连续插补暂停后，单轴相对运动
        /// </summary>
        /// <param name="axis">轴号</param>
        /// <param name="targetPos">目标位置</param>
        /// <param name="minVel">最小速度</param>
        /// <param name="maxVel">最大速度</param>
        /// <param name="stopVel">停止速度</param>
        /// <param name="acc">加速度</param>
        /// <param name="dec">减速度</param>
        /// <param name="smoothTime">平滑时间</param>
        /// <returns>错误码</returns>
        public short ContiPauseAndAxisRelMove(ushort axis, double targetPos, double minVel, double maxVel, double stopVel, double acc, double dec, double smoothTime)
        {
            try
            {
                logger.Info($"卡号：{_cardNo},执行：dmc_conti_pmove_unit_pausemode，轴号{axis}，目标位置：{targetPos},最小速度：{minVel}，最大速度：{maxVel}，停止速度：{stopVel}，加速度：{acc}，减速度：{dec}，平滑时间：{smoothTime}，相对模式");
                return LTDMC.dmc_conti_pmove_unit_pausemode(_cardNo, axis, targetPos, minVel, maxVel, stopVel, acc, dec, smoothTime, 0);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo},执行：dmc_conti_pmove_unit_pausemode，轴号{axis}，目标位置：{targetPos},最小速度：{minVel}，最大速度：{maxVel}，停止速度：{stopVel}，加速度：{acc}，减速度：{dec}，平滑时间：{smoothTime}，相对模式");
                throw;
            }
        }


        /// <summary>
        /// 连续插补暂停后，单轴绝对运动
        /// </summary>
        /// <param name="axis">轴号</param>
        /// <param name="targetPos">目标位置</param>
        /// <param name="minVel">最小速度</param>
        /// <param name="maxVel">最大速度</param>
        /// <param name="stopVel">停止速度</param>
        /// <param name="acc">加速度</param>
        /// <param name="dec">减速度</param>
        /// <param name="smoothTime">平滑时间</param>
        /// <returns>错误码</returns>
        public short ContiPauseAndAxisAbsMove(ushort axis, double targetPos, double minVel, double maxVel, double stopVel, double acc, double dec, double smoothTime)
        {
            try
            {
                logger.Info($"卡号：{_cardNo},执行：dmc_conti_pmove_unit_pausemode，轴号{axis}，目标位置：{targetPos},最小速度：{minVel}，最大速度：{maxVel}，停止速度：{stopVel}，加速度：{acc}，减速度：{dec}，平滑时间：{smoothTime}，绝对模式");
                return LTDMC.dmc_conti_pmove_unit_pausemode(_cardNo, axis, targetPos, minVel, maxVel, stopVel, acc, dec, smoothTime, 1);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo},执行：dmc_conti_pmove_unit_pausemode，轴号{axis}，目标位置：{targetPos},最小速度：{minVel}，最大速度：{maxVel}，停止速度：{stopVel}，加速度：{acc}，减速度：{dec}，平滑时间：{smoothTime}，绝对模式");
                throw;
            }
        }

        /// <summary>
        /// 连续插补暂停，执行单轴运动后，回到暂停位置
        /// </summary>
        /// <param name="axis">轴号</param>
        /// <returns>错误码</returns>
        public short ContiPauseAfterAxisMoveRetPausePos(ushort axis)
        {
            try
            {
                logger.Info($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：dmc_conti_return_pausemode，轴号{axis}");
                return LTDMC.dmc_conti_return_pausemode(_cardNo, ImputationConfig.CrdNo, axis);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：dmc_conti_return_pausemode，轴号{axis}");
                throw;
            }
        }


        /// <summary>
        /// 查询连续插补剩余空间
        /// </summary>
        /// <returns>错误码</returns>
        public int ContiRemainSpace()
        {
            try
            {
                logger.Info($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：dmc_conti_remain_space");
                return LTDMC.dmc_conti_remain_space(_cardNo, ImputationConfig.CrdNo);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：dmc_conti_remain_space");
                throw;
            }
        }

        /// <summary>
        /// 读取连续插补缓冲区当前插补段号
        /// </summary>
        /// <returns>错误码</returns>
        public int ContiReadCurrentMark()
        {
            try
            {
                logger.Info($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：dmc_conti_read_current_mark");
                return LTDMC.dmc_conti_read_current_mark(_cardNo, ImputationConfig.CrdNo);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：dmc_conti_read_current_mark");
                throw;
            }
        }

        /// <summary>
        /// 设置连续插补前瞻参数
        /// </summary>
        /// <param name="enable">前瞻使能状态，0：禁止，1：使能</param>
        /// <param name="lookAheadSegments">前瞻段数，参数保留</param>
        /// <param name="pathError">允许误差范围，取值范围：非负数,单位：unit</param>
        /// <param name="lookaheadAcc">前瞻加速度，参数保留</param>
        /// <returns>错误码</returns>
        public short ContiSetLookaheadMode(ushort enable, int lookAheadSegments, double pathError, double lookaheadAcc)
        {
            try
            {
                logger.Info($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：dmc_conti_set_lookahead_mode,使能:{enable},前瞻段数：{lookAheadSegments}，误差范围:{pathError},前瞻加速度{lookaheadAcc}");
                return LTDMC.dmc_conti_set_lookahead_mode(_cardNo, ImputationConfig.CrdNo, enable, lookAheadSegments, pathError, lookaheadAcc);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：dmc_conti_set_lookahead_mode,使能:{enable},前瞻段数：{lookAheadSegments}，误差范围:{pathError},前瞻加速度{lookaheadAcc}");
                throw;
            }
        }


        /// <summary>
        /// 读取连续插补前瞻参数
        /// </summary>
        /// <param name="enable">前瞻使能状态，0：禁止，1：使能</param>
        /// <param name="lookAheadSegments">前瞻段数，参数保留</param>
        /// <param name="pathError">允许误差范围，取值范围：非负数,单位：unit</param>
        /// <param name="lookaheadAcc">前瞻加速度，参数保留</param>
        /// <returns>错误码</returns>
        public short ContiGetLookaheadMode(ref ushort enable, ref int lookAheadSegments, ref double pathError, ref double lookaheadAcc)
        {
            try
            {
                var res = LTDMC.dmc_conti_get_lookahead_mode(_cardNo, ImputationConfig.CrdNo, ref enable, ref lookAheadSegments, ref pathError, ref lookaheadAcc);
                logger.Info($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：dmc_conti_set_lookahead_mode,使能:{enable},前瞻段数：{lookAheadSegments}，误差范围:{pathError},前瞻加速度{lookaheadAcc}");
                return res;
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：dmc_conti_set_lookahead_mode,使能:{enable},前瞻段数：{lookAheadSegments}，误差范围:{pathError},前瞻加速度{lookaheadAcc}");
                throw;
            }
        }


        /// <summary>
        /// 连续插补位置跟随，位置跟随
        /// 1.进行跟随运动的轴不能是插补坐标系中的轴；发送该指令时轴如果在运动中，指令将不能正常执行；
        /// 2.跟随距离是相对当前位置的相对距离，即下一段插补段运动过程中，跟随轴需要运动的距离。
        /// </summary>
        /// <param name="axisId">跟随轴ID</param>
        /// <param name="dist">跟随距离</param>
        /// <param name="mark">标记号</param>
        /// <returns>错误码</returns>
        public short ContiGearPos(ushort axisId, double dist,int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：位置跟随dmc_conti_gear_unit,跟随轴号:{axisId},跟随距离：{dist}");
                return LTDMC.dmc_conti_gear_unit(_cardNo, ImputationConfig.CrdNo, axisId, dist, 0, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：位置跟随dmc_conti_gear_unit,跟随轴号:{axisId},跟随距离：{dist}");
                throw;
            }
        }

        /// <summary>
        /// 连续插补位置跟随，速度跟随
        /// 1.进行跟随运动的轴不能是插补坐标系中的轴；发送该指令时轴如果在运动中，指令将不能正常执行；
        /// 2.跟随距离是相对当前位置的相对距离，即下一段插补段运动过程中，跟随轴需要运动的距离。
        /// </summary>
        /// <param name="axisId">跟随轴ID</param>
        /// <param name="dist">跟随距离</param>
        /// <param name="mark">标记号</param>
        /// <returns>错误码</returns>
        public short ContiGearVelocity(ushort axisId, double dist, int mark)
        {
            try
            {
                logger.Info($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：速度跟随dmc_conti_gear_unit,跟随轴号:{axisId},跟随距离：{dist}");
                return LTDMC.dmc_conti_gear_unit(_cardNo, ImputationConfig.CrdNo, axisId, dist, 1, mark);
            }
            catch (Exception)
            {
                logger.Error($"卡号：{_cardNo},坐标系：{ImputationConfig.CrdNo}，执行：速度跟随dmc_conti_gear_unit,跟随轴号:{axisId},跟随距离：{dist}");
                throw;
            }
        }


        #endregion

    }
}
